package com.scf.fruit.business.commodity.controller;

import com.scf.fruit.business.commodity.bo.CommodityBo;
import com.scf.fruit.enums.ExceptionCodeEnum;
import com.scf.fruit.util.ResponseVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author : 孙超飞
 * @title :
 * @description :
 * @copyright :
 * @date : 2018-05-21 17:01
 */
@Controller
@RequestMapping(value = "/commodity",produces = "application/json")
public class CommodityController {
    @Resource
    private CommodityBo commodityBo;

    @ResponseBody
    @RequestMapping(value = "/queryCommodityByPage",method = RequestMethod.GET)
    public ResponseVo queryCommodityByPage(@RequestParam("pageNUm")Integer pageNum,@RequestParam("length")Integer length){
        if(0<=pageNum||0<=length){
            return new ResponseVo(ExceptionCodeEnum.EX_PARAM_ERROR.getValue(),ExceptionCodeEnum.EX_PARAM_ERROR.getMsg());
        }
        return commodityBo.queryCommodityByPage(pageNum,length);
    }

    @ResponseBody
    @RequestMapping(value = "/queryCommodityByType",method = RequestMethod.GET)
    public ResponseVo queryCommodityByType(@RequestParam("type")Integer type,@RequestParam("pageNUm")Integer pageNum,@RequestParam("length")Integer length){
        if(0<=pageNum||0<=length){
            return new ResponseVo(ExceptionCodeEnum.EX_PARAM_ERROR.getValue(),ExceptionCodeEnum.EX_PARAM_ERROR.getMsg());
        }
        return commodityBo.queryCommodityByType(type,pageNum,length);
    }
}
